from PySide6.QtCore import (Qt,QObject,QMetaObject,
                            Signal,Slot,
                            QThread,QThreadPool,QTimer,
                            QTemporaryFile,QTemporaryDir,
                            QJsonArray,QJsonDocument,QJsonParseError,QJsonValue,
                            QFile,QFileDevice,QIODevice,QIODeviceBase)


class Worker_Thread(QThread):

    def run(self):
        print("线程任务完成!")
        
        # 线程任务完成，会自动发送信号的,无需手动发送,手动发送可能会导致发送两遍信号.
        # self.finished.emit()
    


class Qt_Custom_Staff_Class(QObject):
    Start_Task = Signal()   # 任务开始信号
    Task_Finish = Signal()   # 任务完成信号
    Current_Completion_Process = Signal(int)
    Emergency_Stop = Signal()  # 紧急停止信号
    OnlyRun = Signal()  # 仅运行信号

    def __init__(self, parent=None):
        super().__init__(parent)
        self.Start_Task.connect(self.RunTask)
        
    @Slot(str)
    def slot_fun(self,text):
        print(f"我是槽函数,我是 {text}")

    # 设置员工属性
    def Set_Staff_Attribute(self,**kwargs):
        pass

    def RunTask(self):
        self.workerthread = Worker_Thread()
        self.workerthread.finished.connect(lambda : self.Task_Finish.emit())
        self.workerthread.finished.connect(lambda : self.workerthread.quit())
        self.workerthread.start()
        